#!/usr/bin/env python
from vtkmodules.vtkCommonCore import vtkPoints
from vtkmodules.vtkCommonDataModel import (
    vtkCellArray,
    vtkPolyData,
)
from vtkmodules.vtkFiltersCore import vtkFeatureEdges
from vtkmodules.vtkFiltersModeling import vtkLoopSubdivisionFilter
from vtkmodules.vtkRenderingCore import (
    vtkActor,
    vtkDataSetMapper,
    vtkPolyDataMapper,
    vtkProperty,
    vtkRenderWindow,
    vtkRenderWindowInteractor,
    vtkRenderer,
)
from vtkmodules.vtkRenderingLOD import vtkLODActor
import vtkmodules.vtkInteractionStyle
import vtkmodules.vtkRenderingFreeType
import vtkmodules.vtkRenderingOpenGL2
from vtkmodules.util.misc import vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()

points = vtkPoints()
points.InsertNextPoint(0,-16,0)
points.InsertNextPoint(0,0,-14)
points.InsertNextPoint(0,0,14)
points.InsertNextPoint(14,0,0)
points.InsertNextPoint(10,20,-10)
points.InsertNextPoint(10,20,10)
points.InsertNextPoint(10,-20,-10)
points.InsertNextPoint(10,-20,10)
points.InsertNextPoint(-10,-20,-10)
points.InsertNextPoint(-10,-20,10)
points.InsertNextPoint(-10,20,-10)
points.InsertNextPoint(-10,20,10)
points.InsertNextPoint(-2,27,0)
points.InsertNextPoint(0,27,2)
points.InsertNextPoint(0,27,-2)
points.InsertNextPoint(2,27,0)
points.InsertNextPoint(-14,4,-1)
points.InsertNextPoint(-14,3,0)
points.InsertNextPoint(-14,5,0)
points.InsertNextPoint(-14,4,1)
points.InsertNextPoint(-1,38,-2)
points.InsertNextPoint(-1,38,2)
points.InsertNextPoint(2,35,-2)
points.InsertNextPoint(2,35,2)
points.InsertNextPoint(17,42,0)
points.InsertNextPoint(15,40,2)
points.InsertNextPoint(15,39,-2)
points.InsertNextPoint(13,37,0)
points.InsertNextPoint(19,-2,-2)
points.InsertNextPoint(19,-2,2)
points.InsertNextPoint(15,2,-2)
points.InsertNextPoint(15,2,2)
faces = vtkCellArray()
faces.InsertNextCell(3)
faces.InsertCellPoint(3)
faces.InsertCellPoint(4)
faces.InsertCellPoint(5)
faces.InsertNextCell(3)
faces.InsertCellPoint(3)
faces.InsertCellPoint(5)
faces.InsertCellPoint(7)
faces.InsertNextCell(3)
faces.InsertCellPoint(3)
faces.InsertCellPoint(7)
faces.InsertCellPoint(6)
faces.InsertNextCell(3)
faces.InsertCellPoint(3)
faces.InsertCellPoint(6)
faces.InsertCellPoint(4)
faces.InsertNextCell(3)
faces.InsertCellPoint(0)
faces.InsertCellPoint(6)
faces.InsertCellPoint(7)
faces.InsertNextCell(3)
faces.InsertCellPoint(0)
faces.InsertCellPoint(7)
faces.InsertCellPoint(9)
faces.InsertNextCell(3)
faces.InsertCellPoint(0)
faces.InsertCellPoint(9)
faces.InsertCellPoint(8)
faces.InsertNextCell(3)
faces.InsertCellPoint(0)
faces.InsertCellPoint(8)
faces.InsertCellPoint(6)
faces.InsertNextCell(3)
faces.InsertCellPoint(1)
faces.InsertCellPoint(4)
faces.InsertCellPoint(6)
faces.InsertNextCell(3)
faces.InsertCellPoint(1)
faces.InsertCellPoint(6)
faces.InsertCellPoint(8)
faces.InsertNextCell(3)
faces.InsertCellPoint(1)
faces.InsertCellPoint(8)
faces.InsertCellPoint(10)
faces.InsertNextCell(3)
faces.InsertCellPoint(1)
faces.InsertCellPoint(10)
faces.InsertCellPoint(4)
faces.InsertNextCell(3)
faces.InsertCellPoint(2)
faces.InsertCellPoint(11)
faces.InsertCellPoint(9)
faces.InsertNextCell(3)
faces.InsertCellPoint(2)
faces.InsertCellPoint(9)
faces.InsertCellPoint(7)
faces.InsertNextCell(3)
faces.InsertCellPoint(2)
faces.InsertCellPoint(7)
faces.InsertCellPoint(5)
faces.InsertNextCell(3)
faces.InsertCellPoint(2)
faces.InsertCellPoint(5)
faces.InsertCellPoint(11)
faces.InsertNextCell(3)
faces.InsertCellPoint(4)
faces.InsertCellPoint(15)
faces.InsertCellPoint(5)
faces.InsertNextCell(3)
faces.InsertCellPoint(4)
faces.InsertCellPoint(14)
faces.InsertCellPoint(15)
faces.InsertNextCell(3)
faces.InsertCellPoint(5)
faces.InsertCellPoint(13)
faces.InsertCellPoint(11)
faces.InsertNextCell(3)
faces.InsertCellPoint(5)
faces.InsertCellPoint(15)
faces.InsertCellPoint(13)
faces.InsertNextCell(3)
faces.InsertCellPoint(11)
faces.InsertCellPoint(12)
faces.InsertCellPoint(10)
faces.InsertNextCell(3)
faces.InsertCellPoint(11)
faces.InsertCellPoint(13)
faces.InsertCellPoint(12)
faces.InsertNextCell(3)
faces.InsertCellPoint(10)
faces.InsertCellPoint(14)
faces.InsertCellPoint(4)
faces.InsertNextCell(3)
faces.InsertCellPoint(10)
faces.InsertCellPoint(12)
faces.InsertCellPoint(14)
faces.InsertNextCell(3)
faces.InsertCellPoint(8)
faces.InsertCellPoint(17)
faces.InsertCellPoint(16)
faces.InsertNextCell(3)
faces.InsertCellPoint(8)
faces.InsertCellPoint(9)
faces.InsertCellPoint(17)
faces.InsertNextCell(3)
faces.InsertCellPoint(9)
faces.InsertCellPoint(19)
faces.InsertCellPoint(17)
faces.InsertNextCell(3)
faces.InsertCellPoint(9)
faces.InsertCellPoint(11)
faces.InsertCellPoint(19)
faces.InsertNextCell(3)
faces.InsertCellPoint(11)
faces.InsertCellPoint(18)
faces.InsertCellPoint(19)
faces.InsertNextCell(3)
faces.InsertCellPoint(11)
faces.InsertCellPoint(10)
faces.InsertCellPoint(18)
faces.InsertNextCell(3)
faces.InsertCellPoint(10)
faces.InsertCellPoint(16)
faces.InsertCellPoint(18)
faces.InsertNextCell(3)
faces.InsertCellPoint(10)
faces.InsertCellPoint(8)
faces.InsertCellPoint(16)
faces.InsertNextCell(3)
faces.InsertCellPoint(13)
faces.InsertCellPoint(21)
faces.InsertCellPoint(12)
faces.InsertNextCell(3)
faces.InsertCellPoint(12)
faces.InsertCellPoint(21)
faces.InsertCellPoint(20)
faces.InsertNextCell(3)
faces.InsertCellPoint(12)
faces.InsertCellPoint(20)
faces.InsertCellPoint(14)
faces.InsertNextCell(3)
faces.InsertCellPoint(14)
faces.InsertCellPoint(20)
faces.InsertCellPoint(22)
faces.InsertNextCell(3)
faces.InsertCellPoint(14)
faces.InsertCellPoint(22)
faces.InsertCellPoint(15)
faces.InsertNextCell(3)
faces.InsertCellPoint(15)
faces.InsertCellPoint(22)
faces.InsertCellPoint(23)
faces.InsertNextCell(3)
faces.InsertCellPoint(15)
faces.InsertCellPoint(23)
faces.InsertCellPoint(13)
faces.InsertNextCell(3)
faces.InsertCellPoint(13)
faces.InsertCellPoint(23)
faces.InsertCellPoint(21)
faces.InsertNextCell(3)
faces.InsertCellPoint(21)
faces.InsertCellPoint(25)
faces.InsertCellPoint(24)
faces.InsertNextCell(3)
faces.InsertCellPoint(21)
faces.InsertCellPoint(24)
faces.InsertCellPoint(20)
faces.InsertNextCell(3)
faces.InsertCellPoint(20)
faces.InsertCellPoint(24)
faces.InsertCellPoint(26)
faces.InsertNextCell(3)
faces.InsertCellPoint(20)
faces.InsertCellPoint(26)
faces.InsertCellPoint(22)
faces.InsertNextCell(3)
faces.InsertCellPoint(22)
faces.InsertCellPoint(26)
faces.InsertCellPoint(27)
faces.InsertNextCell(3)
faces.InsertCellPoint(22)
faces.InsertCellPoint(27)
faces.InsertCellPoint(23)
faces.InsertNextCell(3)
faces.InsertCellPoint(23)
faces.InsertCellPoint(27)
faces.InsertCellPoint(25)
faces.InsertNextCell(3)
faces.InsertCellPoint(23)
faces.InsertCellPoint(25)
faces.InsertCellPoint(21)
faces.InsertNextCell(3)
faces.InsertCellPoint(25)
faces.InsertCellPoint(29)
faces.InsertCellPoint(24)
faces.InsertNextCell(3)
faces.InsertCellPoint(24)
faces.InsertCellPoint(29)
faces.InsertCellPoint(28)
faces.InsertNextCell(3)
faces.InsertCellPoint(24)
faces.InsertCellPoint(28)
faces.InsertCellPoint(26)
faces.InsertNextCell(3)
faces.InsertCellPoint(26)
faces.InsertCellPoint(28)
faces.InsertCellPoint(30)
faces.InsertNextCell(3)
faces.InsertCellPoint(26)
faces.InsertCellPoint(30)
faces.InsertCellPoint(27)
faces.InsertNextCell(3)
faces.InsertCellPoint(27)
faces.InsertCellPoint(30)
faces.InsertCellPoint(31)
faces.InsertNextCell(3)
faces.InsertCellPoint(27)
faces.InsertCellPoint(31)
faces.InsertCellPoint(25)
faces.InsertNextCell(3)
faces.InsertCellPoint(25)
faces.InsertCellPoint(31)
faces.InsertCellPoint(29)
faces.InsertNextCell(3)
faces.InsertCellPoint(29)
faces.InsertCellPoint(19)
faces.InsertCellPoint(17)
faces.InsertNextCell(3)
faces.InsertCellPoint(29)
faces.InsertCellPoint(17)
faces.InsertCellPoint(28)
faces.InsertNextCell(3)
faces.InsertCellPoint(28)
faces.InsertCellPoint(17)
faces.InsertCellPoint(16)
faces.InsertNextCell(3)
faces.InsertCellPoint(28)
faces.InsertCellPoint(16)
faces.InsertCellPoint(30)
faces.InsertNextCell(3)
faces.InsertCellPoint(30)
faces.InsertCellPoint(16)
faces.InsertCellPoint(18)
faces.InsertNextCell(3)
faces.InsertCellPoint(30)
faces.InsertCellPoint(18)
faces.InsertCellPoint(31)
faces.InsertNextCell(3)
faces.InsertCellPoint(31)
faces.InsertCellPoint(18)
faces.InsertCellPoint(19)
faces.InsertNextCell(3)
faces.InsertCellPoint(31)
faces.InsertCellPoint(19)
faces.InsertCellPoint(29)
model = vtkPolyData()
model.SetPolys(faces)
model.SetPoints(points)
# Create the RenderWindow, Renderer and both Actors
#
ren1 = vtkRenderer()
renWin = vtkRenderWindow()
renWin.AddRenderer(ren1)
iren = vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
#vtkButterflySubdivisionFilter subdivide
subdivide = vtkLoopSubdivisionFilter()
subdivide.SetInputData(model)
subdivide.SetNumberOfSubdivisions(4)
mapper = vtkDataSetMapper()
mapper.SetInputConnection(subdivide.GetOutputPort())
rose = vtkLODActor()
rose.SetMapper(mapper)
fe = vtkFeatureEdges()
fe.SetInputConnection(subdivide.GetOutputPort())
fe.SetFeatureAngle(100)
feMapper = vtkPolyDataMapper()
feMapper.SetInputConnection(fe.GetOutputPort())
edges = vtkActor()
edges.SetMapper(feMapper)
# Add the actors to the renderer, set the background and size
#
ren1.AddActor(rose)
#ren1 AddActor edges
backP = vtkProperty()
backP.SetDiffuseColor(1,1,.3)
rose.SetBackfaceProperty(backP)
rose.GetProperty().SetDiffuseColor(1,.4,.3)
rose.GetProperty().SetSpecular(.4)
rose.GetProperty().SetDiffuse(.8)
rose.GetProperty().SetSpecularPower(40)
ren1.SetBackground(0.1,0.2,0.4)
renWin.SetSize(300,300)
# render the image
#
ren1.ResetCamera()
cam1 = ren1.GetActiveCamera()
cam1.Zoom(4.5)
cam1.Azimuth(-90)
ren1.ResetCameraClippingRange()
iren.Initialize()
# prevent the tk window from showing up then start the event loop
# --- end of script --
